package subject_set.lc200;

/**
 * @author haomin
 * @date 2022/12/15 23:10
 **/
public class Num12 {
    class Solution {
        public String intToRoman(int num) {
            String res = "";
            int[] data = new int[]{1,4,5,9,10,40,50,90,100,400,500,900,1000};
            String[] str = new String[]{"I","IV","V","IX","X","XL","L","XC","C","CD","D","CM","M"};
            for(int i = 12; i >= 0; --i) {
                int value = data[i];
                data[i] = num/data[i];
                num -= value * data[i];
                while(data[i]-- > 0) {
                    res += str[i];
                }
            }
            return res;
        }
    }
}